<!--
 * @Descripttion: 
 * @version: 
 * @Author: 
 * @Date: 2019-09-20 15:52:46
 -->
<template>
  <div class="homeLogic">
    <homeView @remoteMethod="remoteMethod"
              :options="options"
              :value="value"
              :list="list"
              :loading="loading"
              :states="states"
              :Versiontime="Versiontime"
              @selectValue="selectValue"></homeView>
  </div>
</template>

<script>
import homeView from './homeView'
export default {

  components: {
    homeView
  },
  name: "homeLogic",
  props: {
    // msg: String //  [name: typeof]
  },
  filters: {

  },
  computed: {

  },
  watch: {

  },
  data () {
    return {
      options: [],
      value: [],
      list: [],
      loading: false,
      states: ["Alabama", "Alaska", "Arizona",
        "Arkansas", "California", "Colorado",
        "Connecticut", "Delaware", "Florida",
        "Georgia", "Hawaii", "Idaho", "Illinois",
        "Indiana", "Iowa", "Kansas", "Kentucky",
        "Louisiana", "Maine", "Maryland",
        "Massachusetts", "Michigan", "Minnesota",
        "Mississippi", "Missouri", "Montana",
        "Nebraska", "Nevada", "New Hampshire",
        "New Jersey", "New Mexico", "New York",
        "North Carolina", "North Dakota", "Ohio",
        "Oklahoma", "Oregon", "Pennsylvania",
        "Rhode Island", "South Carolina",
        "South Dakota", "Tennessee", "Texas",
        "Utah", "Vermont", "Virginia",
        "Washington", "West Virginia", "Wisconsin",
        "Wyoming"],
      Versiontime: '2019-09-17'
    }
  },
  created () {

  },
  mounted () {
    this.list = this.states.map(item => {
      return { value: item, label: item };
    });
  },
  methods: {
    //  搜索框输入
    remoteMethod (query) {
      console.log(query)
      if (query !== '') {
        this.loading = true;
        setTimeout(() => {
          this.loading = false;
          this.options = this.list.filter(item => {
            return item.label.toLowerCase()
              .indexOf(query.toLowerCase()) > -1;
          });
        }, 200);
      } else {
        this.options = [];
      }
    },
    //  搜索框选中
    selectValue (value) {
      console.log(value)
      this.value = value
    }
  },
  destroyed () {

  }
}
</script>

<style scoped lang="less">
.homeLogic {
  width: 100%;
  height: 100%;
}
</style>
